package fr.toto.triseries;

import java.nio.file.Path;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Pattern;

import fr.toto.files.ActionFile;
import fr.toto.subtitles.DldSoutitre;
import fr.toto.subtitles.Soutitre;

/**
 * @author tshepo
 * 
 */
public class DetailFile implements ActionFile {

	private static ExecutorService es;

	public DetailFile() {
		es = Executors.newSingleThreadExecutor();
	}

	@Override
	public void executer(Path file) {
		if (Pattern.compile(Regex.VIDEOFILE).matcher(file.toString()).find())
			es.execute(new Video(file));
		if (Pattern.compile(Regex.SUBTITLEFILE).matcher(file.toString()).find())
			es.execute(new DldSoutitre(file));
	}

	public void executer(Soutitre sub) {
		es.execute(sub);
	}

}
